/**
 * 上海中赢金融信息服务有限公司
 * Copyright (c) 2016-2026 hmc,Inc.All Rights Reserved.
 */
package com.sys.midware.redis.config;

/**
 * RDB配置本地线程变量
 * <b>ClassName：</b> BHBaseConfigHolder <br/>
 * <b>Description：</b> TODO <br/>
 * <b>@author：</b> mobing <br/>
 * <b>@date：</b> 2015年10月26日 下午3:41:52 <br/>
 * <b>@version: </b>  <br/>
 */
public abstract class RedisConfigHolder {
    //本地线程缓存
    private static ThreadLocal<RedisConfig> local = new ThreadLocal<RedisConfig>();
    //静态redisConfig
    private static RedisConfig redisConfig;
    
    public static void put(RedisConfig newNode) {
        if (newNode != null) {
            RedisConfig oldNode = local.get();
            if (oldNode != newNode) {
                local.remove();
                local.set(newNode);
                redisConfig =newNode;
            }
        }
    }

    public static RedisConfig get() {
        if(local.get() == null){
            return redisConfig;
        }
        return local.get();
    }

    public static void remove() {
        local.remove();
    }

}